import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { UserClient } from '../../userClient/assets/userClient.entity';
import { Product } from '../../product/assets/product.entity';
import { Platform } from '../../platform/assets/platform.entity';

@Entity('distributionrate')
export class DistributionRate {
  @PrimaryGeneratedColumn()
  id: number;

  @OneToOne(() => UserClient)
  @ApiProperty({ description: '用户ID', type: () => UserClient })
  @JoinColumn()
  userClient: UserClient;

  @ManyToOne(() => Product)
  @ApiProperty({ description: '规格Id', type: () => Product })
  @JoinColumn()
  product: Product;

  @ManyToOne(() => Platform)
  @ApiProperty({ description: '平台id', type: () => Platform })
  @JoinColumn()
  platform: Platform;

  @Column()
  @ApiProperty({ description: '首单提成' })
  firstOrderRate: number;

  @Column({ nullable: true })
  @ApiProperty({ description: '第二单提成,10即代表10%' })
  secondOrderRate?: number;
}
